﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;

public partial class CampaignBar : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            CampaignData();
        }
    }

    public void CampaignData()
    {
        //string connString = "user id=portalUser;data source=" + Session["servername"] + ";initial catalog=" + Session["projectname"] + ";password=sqluser";
        string connString = "user id=portalUser;data source=172.25.9.26;initial catalog=FAST_Clients;password=sqluser";
        SqlConnection conn = new SqlConnection(connString);
        conn.ConnectionString = connString;
        conn.Open();
        System.Data.SqlClient.SqlCommand command = new System.Data.SqlClient.SqlCommand();
        string lccommand = null;

        lccommand = "select top 1 d.campaignname, d.dnisdesc " +
                    "from DNIS d (NOLOCK) " +
                    "where d.dnis = '" + Session["dnis"] + "' and d.active = 1 ";

        command.CommandType = CommandType.Text;
        command.CommandText = lccommand;
        command.Connection = conn;
        SqlDataReader dr = default(SqlDataReader);
        dr = command.ExecuteReader(CommandBehavior.SingleRow);
        if (dr.HasRows)
        {
            dr.Read();

            lblDNISDesc.Text = dr["dnisdesc"].ToString();
        }
        else
        {
            lblDNISDesc.Text = "Unknown Campaign for listid : " + Session["listid"];
        }

        lblDNISDesc.Font.Size = FontUnit.XXLarge;
        lblDNISDesc.Font.Bold = true;
        lblDNISDesc.ForeColor = System.Drawing.Color.White;


        dr.Close();
        dr = null;
        conn.Close();
    }

}
